package com.ysd.qxgl.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.ysd.qxgl.model.Modules;
import com.ysd.qxgl.service.IRoleModuleService;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/rolemodule")
public class RoleModuleController {

    @Resource
    private IRoleModuleService roleModuleService;

    @ApiOperation(value = "角色设置权限",notes = "给角色设置权限")
    @PostMapping("/setRoleModule")
    public void setRoleModules(String roleId,@RequestParam List<String> moduleId){
        roleModuleService.setRoleModules(roleId, moduleId);
    }
    @ApiOperation(value = "根据角色编号查询角色权限",notes = "根据角色编号查询角色权限")
    @PostMapping("/findRoleModules/{role_id}")
    public Map<String ,Object> findRoleModules(@PathVariable String role_id){
        List<Modules> list=roleModuleService.findRoleModulesById(role_id);
        Map<String ,Object> map=new HashMap<>();
        map.put("code", 0);
        map.put("msg", "查询成功");
        map.put("data", list);
        return map;

    }
}